#ifndef __THREAD_SAFE_POLICY_HH__
#define __THREAD_SAFE_POLICY_HH__

/**
 * @author Olgierd Humenczuk olgierd.humenczuk@gmail.com
 */

#include <boost/thread.hpp>
#include <boost/thread/mutex.hpp>

namespace Common
{

/**
 * @brief Simple and dummy "does nothing" mutex
 */
class DummyMutex
{
};

/**
 * @brief Simple and dummy scoped lock... just in case you need it does nothing
 */
class DummyScopedLock
{
	public:
		DummyScopedLock( DummyMutex& )
		{
		}
};

/**
 * @brief Thread safe policy which defines types of thread mehanism used later
 */
template< bool Condition >
struct ThreadSafePolicy
{
	typedef boost::mutex 				Mutex;
	typedef boost::mutex::scoped_lock 	ScopedLock;
};

/**
 * @brief same as above but for the no thread safe policy
 */
template<>
struct ThreadSafePolicy< false >
{
	typedef DummyMutex 		Mutex;
	typedef DummyScopedLock ScopedLock;
};

//prepare types
typedef ThreadSafePolicy< true > 	ThreadSecured;
typedef ThreadSafePolicy< false > 	ThreadHazardous;

} //namespace Common

#endif
